<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>DBErp 进销存系统<?=$this->translate('后台登录'); ?></title>
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <link rel="icon" href="<?php echo $this->basePath('favicon.ico'); ?>">
    <link rel="stylesheet" href="<?php echo $this->basePath('css/bootstrap/css/bootstrap.min.css'); ?>">
    <link rel="stylesheet" href="<?php echo $this->basePath('css/font-awesome/css/font-awesome.min.css'); ?>">
    <link rel="stylesheet" href="<?php echo $this->basePath('css/Ionicons/css/ionicons.min.css'); ?>">
    <link rel="stylesheet" href="<?php echo $this->basePath('css/admin/css/AdminLTE.css'); ?>">
    <link rel="stylesheet" href="<?php echo $this->basePath('css/admin/css/stylesheet.css'); ?>">
    <link rel="stylesheet" href="<?php echo $this->basePath('js/plugins/iCheck/square/blue.css'); ?>">

    <!--[if lt IE 9]>
    <script src="<?php echo $this->basePath('js/html5shiv.min.js'); ?>"></script>
    <script src="<?php echo $this->basePath('js/respond.min.js'); ?>"></script>
    <![endif]-->
</head>
<body class="hold-transition login-page">
<div class="login-box">
    <div class="login-logo">
        <b>DB</b>Erp
    </div>

    <div class="login-box-body">
        <p class="login-box-msg"><?=$this->translate('输入账号和密码进行登录'); ?></p>
        <?php if(isset($this->loginError)) { ?>
            <div class="alert alert-warning alert-dismissible">
                <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
                <i class="icon fa fa-warning"></i><?=$this->translate('账号或密码错误')?>
            </div>
        <?php } ?>
        <?php
        $form = $this->form;
        $form->prepare();

        $form->get('admin_name')->setAttributes([
                'placeholder' => $this->translate('账号')
        ]);
        $form->get('admin_passwd')->setAttributes([
            'placeholder' => $this->translate('密码')
        ]);
        $form->get('login_captcha')->setAttributes([
            'placeholder' => $this->translate('输入上面的验证码')
        ]);
        $form->get('submit-login')->setAttributes([
            'value' => $this->translate('登 录')
        ]);
        $form->prepare();
        ?>

        <?= $this->form()->openTag($form); ?>
            <div class="form-group">
                <div class="input-group">
                    <div class="input-group-addon">
                        <i class="glyphicon glyphicon-user"></i>
                    </div>
                    <?= $this->formElement($form->get('admin_name')); ?>
                    <?= $this->formElementErrors($form->get('admin_name'), ['class'=>'error-message']); ?>
                </div>
            </div>
            <div class="form-group">
                <div class="input-group">
                    <div class="input-group-addon">
                        <i class="glyphicon glyphicon-lock"></i>
                    </div>
                    <?= $this->formElement($form->get('admin_passwd')); ?>
                    <?= $this->formElementErrors($form->get('admin_passwd'), ['class'=>'error-message']); ?>
                </div>
            </div>
            <div class="form-group">
                <?= $this->formElement($form->get('login_captcha')); ?>
                <?= $this->formElementErrors($form->get('login_captcha'), ['class'=>'error-message']); ?>
                <?= $this->formElement($form->get('login_csrf')); ?>
                <?= $this->formElementErrors($form->get('login_csrf'), ['class'=>'error-message']); ?>
            </div>
            <div class="row">
                <div class="col-xs-6">
                    <div class="checkbox icheck">
                        <label>
                            <?= $this->formElement($form->get('remember_me')); ?> <?=$this->translate('记住我')?>
                        </label>
                    </div>
                </div>
                <div class="col-xs-6">
                    <?= $this->formElement($form->get('submit-login')); ?>
                </div>
                <div class="col-xs-12 text-center">
                    Copyright © <a href="https://www.dberp.com.cn/" target="_blank">北京珑大钜商科技有限公司</a> 版权所有
                </div>
            </div>
        <?= $this->form()->closeTag(); ?>

    </div>

</div>

<script src="<?php echo $this->basePath('js/jquery.min.js'); ?>"></script>
<script src="<?php echo $this->basePath('css/bootstrap/js/bootstrap.min.js'); ?>"></script>
<script src="<?php echo $this->basePath('js/plugins/iCheck/icheck.min.js'); ?>"></script>

<script src="<?php echo $this->basePath('js/plugins/jquery-validation/jquery.validate.js'); ?>"></script>
<script src="<?php echo $this->basePath('js/plugins/jquery-validation/additional-methods.js'); ?>" ></script>
<script src="<?php echo $this->basePath('js/plugins/layer/layer.js'); ?>" ></script>
<script>
    $(document).ready(function() {
        $("#admin-login").validate({
            submitHandler: function(form) {
                if(!$.trim($('#admin_name').val())) {
                    layer.msg('<?=$this->translate('请输入账号')?>');
                    $('#admin_name').focus();
                    return false;
                }
                if(!$.trim($('#admin_passwd').val())) {
                    layer.msg('<?=$this->translate('请输入密码')?>');
                    $('#admin_passwd').focus();
                    return false;
                }
                if(!$.trim($('#login_captcha').val())) {
                    layer.msg('<?=$this->translate('请输入验证码')?>');
                    $('#login_captcha').focus();
                    return false;
                }
                form.submit();
            }
        });

        $('input').iCheck({
            checkboxClass: 'icheckbox_square-blue',
            radioClass: 'iradio_square-blue',
            increaseArea: '20%'
        });
    });
</script>
</body>
</html>
